<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="../assets/js/vue.js"></script>
    <title>v-bind</title>
</head>
<style>
    .red{
        background: red;
    }
    .yellow{
        background: yellow
    }
    .size{
        font-size: 10px;
        color: yellow
    }
</style>
<body>
    <h3>v-bind</h3>
    <hr>
    <h4>v-bind:src</h4>
    <div id="app">
        <div><img v-bind:src="imgSrc" width="200"></div>
        <hr>
        <h4>v-bind的简写</h4>
        <!-- 完整语法 -->
        <a v-bind:href="imgSrc"></a>
        <!-- 缩写 -->
        <a :href="imgSrc"></a>

        <hr>
        <h3>绑定css样式</h3>
        <div :class="red">1、绑定class</div>
        <div :class="{red:isred}">2、在isred为true时显示样式，在isOk为false时不显示样式</div>
        <div :class="isred?red:yellow">3、绑定class中的三元表达式判断</div>
        <div :class="[red,size]">4、绑定class中的数组</div>
        <div :style="{color:red,fontSize:'24px'}">5、绑定Style样式</div>
        <div :style="styleObj">5、绑定Style对象</div>
    </div>
   

</body>
<script>
    var app = new Vue({
        el:"#app",
        data:{
            red:"red",
            yellow:"yellow",
            size:"size",
            isred:false,
            styleObj:{
                fontSize:"20px",
                color:"green"
            },
            imgSrc:'http://baidu.com/wp-content/uploads/2017/02/vue01-2.jpg',
        }
    })
</script>
</html>